﻿using System;
using System.Collections.Generic;
using TaleWorlds.Core;
using TaleWorlds.SaveSystem;

namespace TaleWorlds.CampaignSystem.CampaignBehaviors
{
	// Token: 0x020003B4 RID: 948
	public class OrderOfBattleCampaignBehavior : CampaignBehaviorBase
	{
		// Token: 0x06003A16 RID: 14870 RVA: 0x00111618 File Offset: 0x0010F818
		public OrderOfBattleCampaignBehavior()
		{
			this._siegeFormationInfos = new List<OrderOfBattleCampaignBehavior.OrderOfBattleFormationData>();
			this._fieldBattleFormationInfos = new List<OrderOfBattleCampaignBehavior.OrderOfBattleFormationData>();
		}

		// Token: 0x06003A17 RID: 14871 RVA: 0x00111636 File Offset: 0x0010F836
		public override void RegisterEvents()
		{
		}

		// Token: 0x06003A18 RID: 14872 RVA: 0x00111638 File Offset: 0x0010F838
		public override void SyncData(IDataStore dataStore)
		{
			if (dataStore.SyncData<List<OrderOfBattleCampaignBehavior.OrderOfBattleFormationData>>("_siegeFormationInfos", ref this._siegeFormationInfos) && this._siegeFormationInfos == null)
			{
				this._siegeFormationInfos = new List<OrderOfBattleCampaignBehavior.OrderOfBattleFormationData>();
			}
			if (dataStore.SyncData<List<OrderOfBattleCampaignBehavior.OrderOfBattleFormationData>>("_formationInfos", ref this._fieldBattleFormationInfos) && this._fieldBattleFormationInfos == null)
			{
				this._fieldBattleFormationInfos = new List<OrderOfBattleCampaignBehavior.OrderOfBattleFormationData>();
			}
		}

		// Token: 0x06003A19 RID: 14873 RVA: 0x00111691 File Offset: 0x0010F891
		public OrderOfBattleCampaignBehavior.OrderOfBattleFormationData GetFormationDataAtIndex(int formationIndex, bool isSiegeBattle)
		{
			if (isSiegeBattle)
			{
				if (this._siegeFormationInfos.Count > formationIndex)
				{
					return this._siegeFormationInfos[formationIndex];
				}
				return null;
			}
			else
			{
				if (this._fieldBattleFormationInfos.Count > formationIndex)
				{
					return this._fieldBattleFormationInfos[formationIndex];
				}
				return null;
			}
		}

		// Token: 0x06003A1A RID: 14874 RVA: 0x001116CF File Offset: 0x0010F8CF
		public void SetFormationInfos(List<OrderOfBattleCampaignBehavior.OrderOfBattleFormationData> formationInfos, bool isSiegeBattle)
		{
			if (isSiegeBattle)
			{
				this._siegeFormationInfos = new List<OrderOfBattleCampaignBehavior.OrderOfBattleFormationData>(formationInfos);
				return;
			}
			this._fieldBattleFormationInfos = new List<OrderOfBattleCampaignBehavior.OrderOfBattleFormationData>(formationInfos);
		}

		// Token: 0x040011B0 RID: 4528
		private List<OrderOfBattleCampaignBehavior.OrderOfBattleFormationData> _siegeFormationInfos;

		// Token: 0x040011B1 RID: 4529
		private List<OrderOfBattleCampaignBehavior.OrderOfBattleFormationData> _fieldBattleFormationInfos;

		// Token: 0x02000716 RID: 1814
		public class OrderOfBattleFormationData
		{
			// Token: 0x060058BB RID: 22715 RVA: 0x00183484 File Offset: 0x00181684
			public OrderOfBattleFormationData(Hero commander, List<Hero> heroTroops, DeploymentFormationClass formationClass, int primaryWeight, int secondaryWeight, Dictionary<FormationFilterType, bool> filters)
			{
				this.Commander = commander;
				this.HeroTroops = heroTroops.ToArray();
				this.FormationClass = formationClass;
				this.PrimaryClassWeight = primaryWeight;
				this.SecondaryClassWeight = secondaryWeight;
				this.Filters = new Dictionary<FormationFilterType, bool>();
				foreach (FormationFilterType key in filters.Keys)
				{
					this.Filters.Add(key, filters[key]);
				}
			}

			// Token: 0x060058BC RID: 22716 RVA: 0x00183520 File Offset: 0x00181720
			internal static void AutoGeneratedStaticCollectObjectsOrderOfBattleFormationData(object o, List<object> collectedObjects)
			{
				((OrderOfBattleCampaignBehavior.OrderOfBattleFormationData)o).AutoGeneratedInstanceCollectObjects(collectedObjects);
			}

			// Token: 0x060058BD RID: 22717 RVA: 0x0018352E File Offset: 0x0018172E
			protected virtual void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
			{
				collectedObjects.Add(this.Commander);
				collectedObjects.Add(this.Filters);
				collectedObjects.Add(this.HeroTroops);
			}

			// Token: 0x060058BE RID: 22718 RVA: 0x00183554 File Offset: 0x00181754
			internal static object AutoGeneratedGetMemberValueCommander(object o)
			{
				return ((OrderOfBattleCampaignBehavior.OrderOfBattleFormationData)o).Commander;
			}

			// Token: 0x060058BF RID: 22719 RVA: 0x00183561 File Offset: 0x00181761
			internal static object AutoGeneratedGetMemberValueFormationClass(object o)
			{
				return ((OrderOfBattleCampaignBehavior.OrderOfBattleFormationData)o).FormationClass;
			}

			// Token: 0x060058C0 RID: 22720 RVA: 0x00183573 File Offset: 0x00181773
			internal static object AutoGeneratedGetMemberValuePrimaryClassWeight(object o)
			{
				return ((OrderOfBattleCampaignBehavior.OrderOfBattleFormationData)o).PrimaryClassWeight;
			}

			// Token: 0x060058C1 RID: 22721 RVA: 0x00183585 File Offset: 0x00181785
			internal static object AutoGeneratedGetMemberValueSecondaryClassWeight(object o)
			{
				return ((OrderOfBattleCampaignBehavior.OrderOfBattleFormationData)o).SecondaryClassWeight;
			}

			// Token: 0x060058C2 RID: 22722 RVA: 0x00183597 File Offset: 0x00181797
			internal static object AutoGeneratedGetMemberValueFilters(object o)
			{
				return ((OrderOfBattleCampaignBehavior.OrderOfBattleFormationData)o).Filters;
			}

			// Token: 0x060058C3 RID: 22723 RVA: 0x001835A4 File Offset: 0x001817A4
			internal static object AutoGeneratedGetMemberValueHeroTroops(object o)
			{
				return ((OrderOfBattleCampaignBehavior.OrderOfBattleFormationData)o).HeroTroops;
			}

			// Token: 0x04001DAC RID: 7596
			[SaveableField(1)]
			public readonly Hero Commander;

			// Token: 0x04001DAD RID: 7597
			[SaveableField(2)]
			public readonly DeploymentFormationClass FormationClass;

			// Token: 0x04001DAE RID: 7598
			[SaveableField(3)]
			public readonly int PrimaryClassWeight;

			// Token: 0x04001DAF RID: 7599
			[SaveableField(4)]
			public readonly int SecondaryClassWeight;

			// Token: 0x04001DB0 RID: 7600
			[SaveableField(5)]
			public readonly Dictionary<FormationFilterType, bool> Filters;

			// Token: 0x04001DB1 RID: 7601
			[SaveableField(6)]
			public readonly Hero[] HeroTroops;
		}
	}
}
